/*Includes*/
#include <stdio.h>
#include <windows.h>
#include <mysql/mysql.h>
#include <mysql/mysqld_error.h>
#include <winsock2.h>
# include "Prototipos.h"

#define true 1
#define false 0


extern MYSQL conexao;

int create_tableTelefone() 
 {
   while (mysql_query(&conexao,
                 "CREATE TABLE numtelefone"
                  " (telefone CHAR (13) NOT NULL,"
                  "  PRIMARY KEY  (telefone))"))
   {
     if (mysql_errno(&conexao) != ER_TABLE_EXISTS_ERROR) {
    	mysql_error(&conexao);
     	printf ("MySQL already has example table telefones");
     //return 0;	
	}//if
     /**************
      * Drop table *
      **************/
    if (mysql_query(&conexao, "DROP TABLE numtelefone"))
       mysql_error(&conexao);
   }// while
   return 1;
 }


int create_tableRegistro() 
 {
   while (mysql_query(&conexao,
                 "CREATE TABLE RegistroChamadas"
                  " (data DATE NOT NULL,"
                  " ramal_Origem INTEGER NOT NULL,"
                  " ramal_Destino VARCHAR (15) NOT NULL,"
                  " duracao_Chamada INTEGER NOT NULL,"
                  " tipo_Chamada INTEGER,"
                  " PRIMARY KEY  (data,ramal_Origem))"))
   {
     if (mysql_errno(&conexao) != ER_TABLE_EXISTS_ERROR) {
    	mysql_error(&conexao);
     	printf ("MySQL already has example table RegistroChamadas");
	//return 0;	
	}// if
     /**************
      * Drop table *
      **************/
    if (mysql_query(&conexao, "DROP TABLE RegistroChamadas"))
       mysql_error(&conexao);
   }// while
   return 1;
 }




  
